<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Keep">
    <meta name="description" content="Hexo Theme Keep">
    <meta name="author" content="Jk">
    
    <title>
        
            docker搭建MySQL主从复制 |
        
        即可博客
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo.svg">
    
<link rel="stylesheet" href="/css/font-awesome.min.css">

    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"example.com","root":"/","language":"en"};
    KEEP.theme_config = {"toc":{"enable":true,"number":false,"expand_all":false,"init_open":false},"style":{"primary_color":"#0066CC","avatar":"/images/avatar.svg","favicon":"/images/logo.svg","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":false,"scale":false},"first_screen":{"enable":false,"background_img":"/images/bg.svg","description":"Keep writing and Keep loving."},"scroll":{"progress_bar":{"enable":false},"percent":{"enable":false}}},"local_search":{"enable":false,"preload":false},"code_copy":{"enable":true,"style":"default"},"pjax":{"enable":false},"lazyload":{"enable":false},"version":"3.4.5"};
    KEEP.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
  </script>
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
<div class="progress-bar-container">
    

    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                即可博客
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                HOME
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                ARCHIVES
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/categories"
                            >
                                CATEGORIES
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/tags"
                            >
                                TAGS
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/about"
                            >
                                ABOUT
                            </a>
                        </li>
                    
                    
                </ul>
            </div>
            <div class="mobile">
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">HOME</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">ARCHIVES</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/categories">CATEGORIES</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/tags">TAGS</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/about">ABOUT</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">docker搭建MySQL主从复制</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="/images/avatar.svg">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">Jk</span>
                        
                            <span class="author-label">Lv1</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;
        <span class="pc">2022-09-22 11:32:40</span>
        <span class="mobile">2022-09-22 11:32</span>
    </span>
    
        <span class="article-categories article-meta-item">
            <i class="fas fa-folder"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    
    
        <span class="article-tags article-meta-item">
            <i class="fas fa-tags"></i>&nbsp;
            <ul>
                
                    <li>
                        <a href="/tags/docker/">docker</a>&nbsp;
                    </li>
                
                    <li>
                        | <a href="/tags/MySQL/">MySQL</a>&nbsp;
                    </li>
                
            </ul>
        </span>
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fas fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <h1 id="1-新建主服务器容器示例3307"><a href="#1-新建主服务器容器示例3307" class="headerlink" title="1. 新建主服务器容器示例3307"></a>1. 新建主服务器容器示例3307</h1><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="keyword">run</span><span class="language-bash"> -p 3307:3306 --name mysql-master \</span></span><br><span class="line"><span class="language-bash"></span></span><br><span class="line">-v /mydata/mysql-master/log:/var/log/mysql \</span><br><span class="line"></span><br><span class="line">-v /mydata/mysql-master/data:/var/lib/mysql \</span><br><span class="line"></span><br><span class="line">-v /mydata/mysql-master/conf:/etc/mysql \</span><br><span class="line"></span><br><span class="line">-e MYSQL_ROOT_PASSWORD=root  \</span><br><span class="line"></span><br><span class="line">-d mysql:<span class="number">5.7</span></span><br></pre></td></tr></table></figure>

<h1 id="2-配置主服务器的配置文件"><a href="#2-配置主服务器的配置文件" class="headerlink" title="2. 配置主服务器的配置文件"></a>2. 配置主服务器的配置文件</h1><p>在<font color="#20B2AA">/mydata/mysql-master/conf</font>目录下新建<font color="red">my.cnf</font>文件</p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[client]</span></span><br><span class="line"></span><br><span class="line"><span class="attr">default_character_set</span>=utf8</span><br><span class="line"></span><br><span class="line"><span class="section">[mysqld]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置数据库默认编码格式</span></span><br><span class="line"></span><br><span class="line"><span class="attr">collation_server</span> = utf8_general_ci</span><br><span class="line"></span><br><span class="line"><span class="attr">character_set_server</span> = utf8</span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置server_id，同一局域网中需要唯一</span></span><br><span class="line"></span><br><span class="line"><span class="attr">server_id</span>=<span class="number">101</span> </span><br><span class="line"></span><br><span class="line"><span class="comment">## 指定不需要同步的数据库名称</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog-ignore-db</span>=mysql  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 开启二进制日志功能</span></span><br><span class="line"></span><br><span class="line"><span class="attr">log-bin</span>=mall-mysql-bin  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置二进制日志使用内存大小（事务）</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog_cache_size</span>=<span class="number">1</span>M  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置使用的二进制日志格式（mixed,statement,row）</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog_format</span>=mixed  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 二进制日志过期清理时间。默认值为0，表示不自动清理。</span></span><br><span class="line"></span><br><span class="line"><span class="attr">expire_logs_days</span>=<span class="number">7</span>  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 跳过主从复制中遇到的所有错误或指定类型的错误，避免slave端复制中断。</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 如：1062错误是指一些主键重复，1032错误是因为主从数据库数据不一致</span></span><br><span class="line"></span><br><span class="line"><span class="attr">slave_skip_errors</span>=<span class="number">1062</span></span><br></pre></td></tr></table></figure>

<h1 id="3-修改完配置后重启master示例"><a href="#3-修改完配置后重启master示例" class="headerlink" title="3. 修改完配置后重启master示例"></a>3. 修改完配置后重启master示例</h1><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker restart mysql-master</span><br></pre></td></tr></table></figure>

<h1 id="4-进入mysql-master容器"><a href="#4-进入mysql-master容器" class="headerlink" title="4. 进入mysql-master容器"></a>4. 进入mysql-master容器</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">exec</span> -it mysql-master /bin/bash</span><br><span class="line">mysql -uroot -p</span><br></pre></td></tr></table></figure>

<h1 id="5-master容器实例中创建数据同步账户"><a href="#5-master容器实例中创建数据同步账户" class="headerlink" title="5. master容器实例中创建数据同步账户"></a>5. master容器实例中创建数据同步账户</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> <span class="string">&#x27;slave&#x27;</span>@<span class="string">&#x27;%&#x27;</span> IDENTIFIED <span class="keyword">BY</span> <span class="string">&#x27;123456&#x27;</span>;</span><br><span class="line"><span class="keyword">GRANT</span> REPLICATION SLAVE,REPLICATION CLIENT <span class="keyword">ON</span> <span class="operator">*</span>.<span class="operator">*</span> <span class="keyword">TO</span> <span class="string">&#x27;slave&#x27;</span>@<span class="string">&#x27;%&#x27;</span> </span><br></pre></td></tr></table></figure>

<h1 id="6-新建从服务器示例3308"><a href="#6-新建从服务器示例3308" class="headerlink" title="6. 新建从服务器示例3308"></a>6. 新建从服务器示例3308</h1><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="keyword">run</span><span class="language-bash"> -p 3308:3306 --name mysql-slave \</span></span><br><span class="line"><span class="language-bash"></span></span><br><span class="line">-v /mydata/mysql-slave/log:/var/log/mysql \</span><br><span class="line"></span><br><span class="line">-v /mydata/mysql-slave/data:/var/lib/mysql \</span><br><span class="line"></span><br><span class="line">-v /mydata/mysql-slave/conf:/etc/mysql \</span><br><span class="line"></span><br><span class="line">-e MYSQL_ROOT_PASSWORD=root  \</span><br><span class="line"></span><br><span class="line">-d mysql:<span class="number">5.7</span></span><br></pre></td></tr></table></figure>

<h1 id="7-修改从服务器配置文件"><a href="#7-修改从服务器配置文件" class="headerlink" title="7. 修改从服务器配置文件"></a>7. 修改从服务器配置文件</h1><figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">[client]</span></span><br><span class="line"></span><br><span class="line"><span class="attr">default_character_set</span>=utf8</span><br><span class="line"></span><br><span class="line"><span class="section">[mysqld]</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置数据库默认编码格式</span></span><br><span class="line"></span><br><span class="line"><span class="attr">collation_server</span> = utf8_general_ci</span><br><span class="line"></span><br><span class="line"><span class="attr">character_set_server</span> = utf8</span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置server_id，同一局域网中需要唯一</span></span><br><span class="line"></span><br><span class="line"><span class="attr">server_id</span>=<span class="number">102</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 指定不需要同步的数据库名称</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog-ignore-db</span>=mysql  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 开启二进制日志功能，以备Slave作为其它数据库实例的Master时使用</span></span><br><span class="line"></span><br><span class="line"><span class="attr">log-bin</span>=mall-mysql-slave1-bin  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置二进制日志使用内存大小（事务）</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog_cache_size</span>=<span class="number">1</span>M  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 设置使用的二进制日志格式（mixed,statement,row）</span></span><br><span class="line"></span><br><span class="line"><span class="attr">binlog_format</span>=mixed  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 二进制日志过期清理时间。默认值为0，表示不自动清理。</span></span><br><span class="line"></span><br><span class="line"><span class="attr">expire_logs_days</span>=<span class="number">7</span>  </span><br><span class="line"></span><br><span class="line"><span class="comment">## 跳过主从复制中遇到的所有错误或指定类型的错误，避免slave端复制中断。</span></span><br><span class="line"></span><br><span class="line"><span class="comment">## 如：1062错误是指一些主键重复，1032错误是因为主从数据库数据不一致</span></span><br><span class="line"></span><br><span class="line"><span class="attr">slave_skip_errors</span>=<span class="number">1062</span>  </span><br><span class="line"></span><br><span class="line"><span class="comment">## relay_log配置中继日志</span></span><br><span class="line"></span><br><span class="line"><span class="attr">relay_log</span>=mall-mysql-relay-bin  </span><br><span class="line"></span><br><span class="line"><span class="comment">## log_slave_updates表示slave将复制事件写进自己的二进制日志</span></span><br><span class="line"></span><br><span class="line"><span class="attr">log_slave_updates</span>=<span class="number">1</span>  </span><br><span class="line"></span><br><span class="line"><span class="comment">## slave设置为只读（具有super权限的用户除外）</span></span><br><span class="line"></span><br><span class="line"><span class="attr">read_only</span>=<span class="number">1</span></span><br></pre></td></tr></table></figure>

<h1 id="8-修改完配置后重启slave示例"><a href="#8-修改完配置后重启slave示例" class="headerlink" title="8. 修改完配置后重启slave示例"></a>8. 修改完配置后重启slave示例</h1><figure class="highlight docker"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker restart mysql-slave</span><br></pre></td></tr></table></figure>

<h1 id="9-在主数据库查看主从同步状态"><a href="#9-在主数据库查看主从同步状态" class="headerlink" title="9. 在主数据库查看主从同步状态"></a>9. 在主数据库查看主从同步状态</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">show</span> master status;</span><br></pre></td></tr></table></figure>

<h1 id="10-进入mysql-slave容器"><a href="#10-进入mysql-slave容器" class="headerlink" title="10. 进入mysql-slave容器"></a>10. 进入mysql-slave容器</h1><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">exec</span> -it mysql-slave /bin/bash</span><br><span class="line">mysql -uroot -p</span><br></pre></td></tr></table></figure>

<h1 id="11-在从数据库中配置主从复制"><a href="#11-在从数据库中配置主从复制" class="headerlink" title="11. 在从数据库中配置主从复制"></a>11. 在从数据库中配置主从复制</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">change master <span class="keyword">to</span> master_host<span class="operator">=</span><span class="string">&#x27;宿主机ip&#x27;</span>, master_user<span class="operator">=</span><span class="string">&#x27;slave&#x27;</span>, </span><br><span class="line">                 master_password<span class="operator">=</span><span class="string">&#x27;123456&#x27;</span>, master_port<span class="operator">=</span><span class="number">3307</span>, </span><br><span class="line">                 master_log_file<span class="operator">=</span><span class="string">&#x27;mall-mysql-bin.000001&#x27;</span>,</span><br><span class="line">                 master_log_pos<span class="operator">=</span><span class="number">617</span>, master_connect_retry<span class="operator">=</span><span class="number">30</span>;</span><br></pre></td></tr></table></figure>

<p>参数说明：</p>
<figure class="highlight md"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">master<span class="emphasis">_host：主数据库的IP地址；</span></span><br><span class="line"><span class="emphasis"></span></span><br><span class="line"><span class="emphasis">master_</span>port：主数据库的运行端口；</span><br><span class="line"></span><br><span class="line">master<span class="emphasis">_user：在主数据库创建的用于同步数据的用户账号；</span></span><br><span class="line"><span class="emphasis"></span></span><br><span class="line"><span class="emphasis">master_</span>password：在主数据库创建的用于同步数据的用户密码；</span><br><span class="line"></span><br><span class="line">master<span class="emphasis">_log_</span>file：指定从数据库要复制数据的日志文件，通过查看主数据的状态，获取File参数；</span><br><span class="line"></span><br><span class="line">master<span class="emphasis">_log_</span>pos：指定从数据库从哪个位置开始复制数据，通过查看主数据的状态，获取Position参数；</span><br><span class="line"></span><br><span class="line">master<span class="emphasis">_connect_</span>retry：连接失败重试的时间间隔，单位为秒。</span><br></pre></td></tr></table></figure>

<h1 id="12-在从服务器中开启主从同步"><a href="#12-在从服务器中开启主从同步" class="headerlink" title="12. 在从服务器中开启主从同步"></a>12. 在从服务器中开启主从同步</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">start</span> slave;</span><br></pre></td></tr></table></figure>

<h1 id="13-在从服务器中查看主从同步状态"><a href="#13-在从服务器中查看主从同步状态" class="headerlink" title="13. 在从服务器中查看主从同步状态"></a>13. 在从服务器中查看主从同步状态</h1><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">show</span> slave status\G;</span><br></pre></td></tr></table></figure>

<p>done。</p>

        </div>

        

        
            <ul class="post-tags-box">
                
                    <li class="tag-item">
                        <a href="/tags/docker/">#docker</a>&nbsp;
                    </li>
                
                    <li class="tag-item">
                        <a href="/tags/MySQL/">#MySQL</a>&nbsp;
                    </li>
                
            </ul>
        

        
            <div class="article-nav">
                
                    <div class="article-prev">
                        <a class="prev"
                           rel="prev"
                           href="/2022/09/22/hello-world/"
                        >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                            <span class="title flex-center">
                                <span class="post-nav-title-item">Hello World</span>
                                <span class="post-nav-item">Prev posts</span>
                            </span>
                        </a>
                    </div>
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/2022/09/22/Zookeeper%E8%AF%A6%E8%A7%A3/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">Zookeeper详解</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2020</span>
              -
            
            2022&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">Jk</a>
        </div>
        
            <script async  src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            <div class="website-count info-item">
                
                    <span id="busuanzi_container_site_uv">
                        Visitor Count&nbsp;<span id="busuanzi_value_site_uv"></span>&ensp;
                    </span>
                
                
                    <span id="busuanzi_container_site_pv">
                        Totalview&nbsp;<span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.4.5</a>
        </div>
        
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        
            <li class="tools-item page-aside-toggle">
                <i class="fas fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    
        <aside class="page-aside">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-%E6%96%B0%E5%BB%BA%E4%B8%BB%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%AE%B9%E5%99%A8%E7%A4%BA%E4%BE%8B3307"><span class="nav-text">1. 新建主服务器容器示例3307</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-%E9%85%8D%E7%BD%AE%E4%B8%BB%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">2. 配置主服务器的配置文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-%E4%BF%AE%E6%94%B9%E5%AE%8C%E9%85%8D%E7%BD%AE%E5%90%8E%E9%87%8D%E5%90%AFmaster%E7%A4%BA%E4%BE%8B"><span class="nav-text">3. 修改完配置后重启master示例</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#4-%E8%BF%9B%E5%85%A5mysql-master%E5%AE%B9%E5%99%A8"><span class="nav-text">4. 进入mysql-master容器</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#5-master%E5%AE%B9%E5%99%A8%E5%AE%9E%E4%BE%8B%E4%B8%AD%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E5%90%8C%E6%AD%A5%E8%B4%A6%E6%88%B7"><span class="nav-text">5. master容器实例中创建数据同步账户</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#6-%E6%96%B0%E5%BB%BA%E4%BB%8E%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%A4%BA%E4%BE%8B3308"><span class="nav-text">6. 新建从服务器示例3308</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#7-%E4%BF%AE%E6%94%B9%E4%BB%8E%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">7. 修改从服务器配置文件</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#8-%E4%BF%AE%E6%94%B9%E5%AE%8C%E9%85%8D%E7%BD%AE%E5%90%8E%E9%87%8D%E5%90%AFslave%E7%A4%BA%E4%BE%8B"><span class="nav-text">8. 修改完配置后重启slave示例</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#9-%E5%9C%A8%E4%B8%BB%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9F%A5%E7%9C%8B%E4%B8%BB%E4%BB%8E%E5%90%8C%E6%AD%A5%E7%8A%B6%E6%80%81"><span class="nav-text">9. 在主数据库查看主从同步状态</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#10-%E8%BF%9B%E5%85%A5mysql-slave%E5%AE%B9%E5%99%A8"><span class="nav-text">10. 进入mysql-slave容器</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#11-%E5%9C%A8%E4%BB%8E%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%AD%E9%85%8D%E7%BD%AE%E4%B8%BB%E4%BB%8E%E5%A4%8D%E5%88%B6"><span class="nav-text">11. 在从数据库中配置主从复制</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#12-%E5%9C%A8%E4%BB%8E%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%AD%E5%BC%80%E5%90%AF%E4%B8%BB%E4%BB%8E%E5%90%8C%E6%AD%A5"><span class="nav-text">12. 在从服务器中开启主从同步</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#13-%E5%9C%A8%E4%BB%8E%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%AD%E6%9F%A5%E7%9C%8B%E4%B8%BB%E4%BB%8E%E5%90%8C%E6%AD%A5%E7%8A%B6%E6%80%81"><span class="nav-text">13. 在从服务器中查看主从同步状态</span></a></li></ol>
    </div>
</div>
        </aside>
    

    <div class="image-viewer-container">
    <img src="">
</div>


    

</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/header-shrink.js"></script>

<script src="/js/back2top.js"></script>

<script src="/js/dark-light-toggle.js"></script>





    
<script src="/js/code-copy.js"></script>





<div class="post-scripts">
    
        
<script src="/js/left-side-toggle.js"></script>

<script src="/js/libs/anime.min.js"></script>

<script src="/js/toc.js"></script>

    
</div>



</body>
</html>
